package edu.nf.bs.dao.impl;

import edu.nf.bs.dao.LogisticsMapper;
import edu.nf.bs.entity.Logistics;
import edu.nf.bs.util.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class LogisticsMapperImpl implements LogisticsMapper {
    @Override
    public List<Logistics> queryLogistics(String logistics, Integer pageNum, Integer pageSize) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession(true);
        LogisticsMapper mapper = sqlSession.getMapper(LogisticsMapper.class);
        List<Logistics> logisticsList = mapper.queryLogistics(logistics, pageNum, pageSize);
        sqlSession.close();
        return logisticsList;
    }

    @Override
    public Integer updateLogisticsStatus(String logisticsId) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession(true);
        LogisticsMapper mapper = sqlSession.getMapper(LogisticsMapper.class);
        Integer integer = mapper.updateLogisticsStatus(logisticsId);
        sqlSession.close();
        return integer;
    }

    @Override
    public Integer addLogistics(Logistics logistics) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession(true);
        LogisticsMapper mapper = sqlSession.getMapper(LogisticsMapper.class);
        Integer integer = mapper.addLogistics(logistics);
        sqlSession.close();
        return integer;
    }
}
